/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package aptech.semester.code.custom.component;

import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JFormattedTextField;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;


/**
 *
 * @author vi
 */
public class IntegerTableCellEditor extends AbstractCellEditor implements TableCellEditor {

    JFormattedTextField component = new JFormattedTextField(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getIntegerInstance())));

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
            int rowIndex, int vColIndex) {

        //((JFormattedTextField) component).setText(Integer.parseInt(value.toString()));

        return component;
    }

    @Override
    public Object getCellEditorValue() {
        return ((JFormattedTextField) component).getText();
    }

}
